import java.util.*;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.offer(1);
        myQueue.offer(2);
        myQueue.offer(3);
        myQueue.offer(4);
        // 4   3   2   1

        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
    }

    public static void main3(String[] args) {
        Deque<Integer> queue2 = new LinkedList<>();
        Deque<Integer> queue22 = new ArrayDeque<>();
        queue22.offer(1);


        Deque<Integer> stack = new ArrayDeque<>();

        stack.push(1);




        Queue<Integer> queue1 = new LinkedList<>();
        queue1.offer(1);
        queue1.offer(2);
        queue1.offer(3);

        System.out.println(queue1.poll());
        System.out.println(queue1.peek());

    }

    public static void main2(String[] args) {
        LinkedList<Integer> stack = new LinkedList<>();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        System.out.println(stack.peek());
    }

    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushA.length; i++) {
            stack.push(pushA[i]);
            while (!stack.empty() && j < popA.length &&
                    stack.peek() == popA[j]) {
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }

    /**
     * 只要是左括号 就入栈
     * 遇到右括号 就开始匹配
     *     1. 和栈顶不匹配
     *     2. 栈为空
     *     3. 栈不为空 但是字符串遍历完了
     * @param s
     * @return
     */
    public boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for(int i = 0;i < s.length();i++) {
            char ch = s.charAt(i);//肯定是括号！
            if(ch == '(' || ch == '{' || ch == '[') {
                //左括号
                stack.push(ch);

            }else {
                //右括号
                if(stack.empty()) {
                    return false;
                }
                char top = stack.peek();
                //此时top是左括号 ch是右括号
                if(ch == ')' && top == '('  || ch == '}' && top == '{' || ch == ']' && top == '[') {
                    stack.pop();//
                }else{
                    return false;
                }
            }

        }
        if(!stack.empty()) {
            return false;
        }
        return true;
    }

    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();
        for(String s : tokens) {
            if(!isOperation(s)) {
                //数字 字符
                stack.push(Integer.parseInt(s));
            }else {
                // 有可能是加减乘除 当中的一个运算符
                int num2 = stack.pop();
                int num1 = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(num1 + num2);
                        break;
                    case "-":
                        stack.push(num1 - num2);
                        break;
                    case "*":
                        stack.push(num1 * num2);
                        break;
                    case "/":
                        stack.push(num1 / num2);
                        break;
                }
            }
        }
        return stack.pop();
    }
    private boolean isOperation(String s) {
        if(s.equals("+") || s.equals("-") || s.equals("*") || s.equals("/")) {
            return true;
        }
        return false;
    }

    public static void main11(String[] args) {
        MyStack myStack = new MyStack();
        myStack.push(1);
        myStack.push(2);
        myStack.push(3);

        System.out.println(myStack.peek());//3
        System.out.println(myStack.pop());//3
        System.out.println(myStack.pop());//2
        System.out.println(myStack.pop());//1
        System.out.println(myStack.isEmpty());//true
        System.out.println(myStack.pop());//异常
    }
    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(12);
        stack.push(23);
        stack.push(34);

        Integer x = stack.pop();
        System.out.println(x);

        int ret = stack.peek();
        System.out.println(ret);

        ret = stack.peek();
        System.out.println(ret);


        System.out.println(stack.size());



    }
}
